﻿using MyFloridaHouse.libSvDTO;
using MyFloridaHouse.libSvOpenDistricts.Districts;

namespace MyFloridaHouse.libSvOpenDistricts.PDF
{

    public class HouseMapLayoutState : HouseMap
    {

        const double floridaPanhandleHeightPercent = .29;
        const double insertOuterMarginHeightPercent = .01;
        const double tallInsertHeightPercent = .69;

        const double insertWidthPercent = .26;

        const double shortInsertHeightPercent = .21;
        const double shortInsertInnerVerticalMarginPercent = .03;

        const double insertMarginWidthPercent = .01;

        public HouseMapLayoutState(PDF_DAL pdfDAL, enumDistrictPlanPDFPrintSizes pageSize, DistrictPlan districtPlan, string mainTitle)
            : base(pdfDAL, pageSize, districtPlan, mainTitle)
        {
            double floridaInsertZoomLevel;
            double goldCoastInsertZoomLevel;
            double jacksonvilleInsertZoomLevel;
            double orlandoInsertZoomLevel;
            double tampaInsertZoomLevel;
            int fontSize;

            if (enumDistrictPlanPDFPrintSizes._8x11 == pageSize)
            {
                // SMALL
                this.pageOrientation = enumPDFPageOrientation.Landscape;
                floridaInsertZoomLevel = 7;
                goldCoastInsertZoomLevel = 12;
                jacksonvilleInsertZoomLevel = 12;
                orlandoInsertZoomLevel = 12;
                tampaInsertZoomLevel = 12;

                fontSize = 12;

            }
            else
            {
                // LARGE
                this.pageOrientation = enumPDFPageOrientation.Portrait;
                floridaInsertZoomLevel = 10;
                goldCoastInsertZoomLevel = 16;
                jacksonvilleInsertZoomLevel = 16;
                orlandoInsertZoomLevel = 16;
                tampaInsertZoomLevel = 16;

                fontSize = 40;

            }

            // all insert origins and widths are in percent of the mapBorder, makes it very easy to specify
            HouseMapInset inset;

            inset = new HouseMapInset(0.0, 0.0, 1.0, 1.0, floridaLatLon, floridaInsertZoomLevel, false);
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.shorelines));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.majorHighways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.expressways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.counties));
            insetList.Add(inset);

            inset = new HouseMapInset(.01, .29, .26, .69, goldCoastLatLon, goldCoastInsertZoomLevel, true);
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.shorelines));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.majorHighways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.expressways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.counties));
            insetList.Add(inset);

            inset = new HouseMapInset(.28, .29, .26, .21, jacksonvilleLatLon, jacksonvilleInsertZoomLevel, true);
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.shorelines));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.majorHighways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.expressways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.counties));
            insetList.Add(inset);

            inset = new HouseMapInset(.28, .53, .26, .21, orlandoLatLon, orlandoInsertZoomLevel, true);
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.shorelines));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.majorHighways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.expressways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.counties));
            insetList.Add(inset);

            inset = new HouseMapInset(.28, .77, .26, .21, tampaLatLon, tampaInsertZoomLevel, true);
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.shorelines));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.majorHighways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.expressways));
            inset.mapLayerRegionsList.Add(new HouseMapLayerRegions(HouseMapShapeTypes.counties));
            insetList.Add(inset);

            insetLabelList.Add(new HouseMapLabel( .01, .29, "GOLD COAST", fontSize));
            insetLabelList.Add(new HouseMapLabel( .28, .29, "JACKSONVILLE", fontSize));
            insetLabelList.Add(new HouseMapLabel( .28, .53, "ORLANDO", fontSize));
            insetLabelList.Add(new HouseMapLabel( .28, .77, "TAMPA", fontSize));

            GetDataAndDrawDocument();
        }
    }
}
